package com.dstz.form.util;

import jxl.format.Alignment;
import jxl.format.CellFormat;
import jxl.write.DateFormat;
import jxl.write.NumberFormat;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WriteException;

/**
 * Jxl 工具类
 */
public abstract class JxlUtils {
	
	/**
	 * 字体大小-默认
	 */
	public static final int DEF_FONT_SIZE = WritableFont.DEFAULT_POINT_SIZE;
	
	/**
	 * 字体大小-标题
	 */
	public static final int TITLE_FONT_SIZE = 16;
	
	/**
	 * 字体大小-子标题
	 */
	public static final int SUB_TITLE_FONT_SIZE = 12;
	
	/**
	 * 单元格式-标题
	 * @return
	 */
	public static WritableCellFormat createTitleFormat() {
		WritableCellFormat wcf = new WritableCellFormat(
		        new WritableFont(WritableFont.TAHOMA, TITLE_FONT_SIZE, WritableFont.BOLD));
		try {
			wcf.setAlignment(Alignment.CENTRE);
		} catch (WriteException e) {
			e.printStackTrace();
		}
		
		return wcf;
	}
	
	/**
	 * 单元格式-列名
	 * @return
	 */
	public static CellFormat createColumnFormat() {
		return new WritableCellFormat(new WritableFont(WritableFont.TAHOMA, DEF_FONT_SIZE, WritableFont.BOLD));
	}
	
	/**
	 * 单元格式-金额
	 * @return
	 */
	public static CellFormat createMoneyFormat() {
		return new WritableCellFormat(new NumberFormat("#,###,###,##0.00"));
	}
	
	/**
	 * 单元格式-数字
	 * @return
	 */
	public static CellFormat createNumberFormat() {
		return new WritableCellFormat(new NumberFormat("0.00"));
	}
	
	/**
	 * 单元格式-整型
	 * @return
	 */
	public static CellFormat createIntFormat() {
		return new WritableCellFormat(new NumberFormat("0"));
	}
	
	/**
	 * 单元格式-日期 时间
	 * @return
	 */
	public static CellFormat createDatetimeFormat() {
		return new WritableCellFormat(new DateFormat("yyyy-MM-dd HH:mm:ss"));
	}
	
	/**
	 * 单元格式-日期
	 * @return
	 */
	public static CellFormat createDateFormat() {
		return new WritableCellFormat(new DateFormat("yyyy-MM-dd"));
	}
	
	/**
	 * 单元格式-时间
	 * @return
	 */
	public static CellFormat createTimeFormat() {
		return new WritableCellFormat(new DateFormat("HH:mm:ss"));
	}
	
}
